﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace RentACarRESTApi.Models
{
    public class Reservation
    {
        public int ID { get; set; }
        public int IdCarReserved { get; set; }
        public DateTime StartDate { get; set; }
        public DateTime EndDate { get; set; }
        public List<Link> Links { get; set; }

        private static int reservationsCount = 0;

        private void BasicInitialize()
        { 
            reservationsCount++;
            ID = reservationsCount;
            Links = new List<Link>()
            {
                new Link(rel: "/linkrels/reservation/cancel", uri: "/api/reservations/" + ID),
                new Link(rel: "/linkrels/reservation/change", uri: "/api/reservations/" + ID),
                new Link(rel: "/linkrels/car/details", uri: "/api/cars/" + IdCarReserved)
            };
        }

        public Reservation()
        {

        }

        public Reservation(int idCarReserved, DateTime startDate, DateTime endDate) 
        {
            this.IdCarReserved = idCarReserved;
            this.StartDate = startDate;
            this.EndDate = endDate;

            BasicInitialize();            
        }
    }
}